package com.hsy.linemoney.apiservice;

import com.hsy.linemoney.R;
import com.hsy.linemoney.requests.RequestTask;
import com.hsy.linemoney.utils.ToastUtil;

import org.json.JSONArray;
import org.json.JSONObject;

/**
 * Created by Administrator on 2017/1/13.
 */

public class ExchangeService extends BasicService<JSONArray> {

    //兑换检验
    public void verified(final JSONObject params, final Callback<JSONArray> callback, final boolean... defaultHandle) {
        String api = "/LmBusinessServices-portlet.order/need-to-be-verified";
        invoke(0, api, params, new Callback<JSONArray>() {
            @Override
            public void onSuccess(int what, JSONArray result) {
                if (null != callback) {
                    callback.onSuccess(what, result);
                }
            }

            @Override
            public void onError(int what, int type, String msg, Exception e) {
                if (e instanceof RequestTask.StatusCodeException && (null == defaultHandle || 0 == defaultHandle.length || defaultHandle[0])) {
                    ToastUtil.showToast(msg);
                } else {
                    ToastUtil.showToast(R.string.txt_network_failure);
                }
                if (null != callback) {
                    callback.onError(0, 0, e.getLocalizedMessage(), e);
                }
            }
        },false);
    }
}
